package cn.tedu.tw.whr.jdbc;


import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class AppJdbcSelect {
    public static void main(String[] args) throws Exception {

        Class.forName("com.mysql.jdbc.Driver");

        String url = "jdbc:mysql://localhost:3306/test?useSSL=false";
        String username = "root";
        String password = "root";

        Connection connection = DriverManager.getConnection(url, username, password);
        Statement statement = connection.createStatement();

        String sql = "SELECT `id`,`username`,`password` from `user`";

        ResultSet set = statement.executeQuery(sql);
        boolean next = set.next();
        System.out.println(String.valueOf(next));

//        set.next();
//        // 获取第一列的值
//        String string = set.getString(1);
//        String string1 = set.getString(2);
//        String string2 = set.getString(3);
//        System.out.println(string + string1 + string2);

        

        while (set.next()) {
            String v = set.getString(2);
            Long id = set.getLong(1);
            String p = set.getString(3);
            System.out.println("id is: " + id + ", username is : " + v + ", password is : " + p);


        }
    }
}